//
// File: speye.cpp
//
// MATLAB Coder version            : 5.4
// C/C++ source code generated on  : 27-Mar-2025 11:51:36
//

// Include Files
#include "speye.h"
#include "rt_nonfinite.h"
#include "sparse.h"
#include "coder_array.h"

// Function Definitions
//
// Arguments    : double m
//                sparse *y
// Return Type  : void
//
namespace coder {
void speye(double m, sparse *y)
{
  int ndiag_tmp_tmp;
  int nzmax;
  ndiag_tmp_tmp = static_cast<int>(m);
  nzmax = static_cast<int>(m);
  y->m = static_cast<int>(m);
  y->n = static_cast<int>(m);
  if (static_cast<int>(m) < 1) {
    nzmax = 1;
  }
  y->maxnz = nzmax;
  y->d.set_size(nzmax);
  y->rowidx.set_size(nzmax);
  nzmax = static_cast<int>(m) + 1;
  y->colidx.set_size(nzmax);
  for (int i{0}; i < ndiag_tmp_tmp; i++) {
    y->d[i] = 1.0;
    y->rowidx[i] = i + 1;
  }
  y->colidx[0] = 1;
  for (int i{2}; i <= ndiag_tmp_tmp; i++) {
    y->colidx[i - 1] = i;
  }
  for (int i{nzmax}; i <= nzmax; i++) {
    y->colidx[i - 1] = static_cast<int>(m) + 1;
  }
}

} // namespace coder

//
// File trailer for speye.cpp
//
// [EOF]
//
